import logging, os
from vouchers.certificate.AlipayClientConfig import AlipayClientConfig
from vouchers.certificate.CertDefaultAlipayClient import CertDefaultAlipayClient
from alipay.aop.api.request.AlipaySystemOauthTokenRequest import AlipaySystemOauthTokenRequest
from alipay.aop.api.request.AlipayMarketingVoucherSendRequest import AlipayMarketingVoucherSendModel, AlipayMarketingVoucherSendRequest
from alipay.aop.api.request.AlipayMarketingVoucherQueryRequest import AlipayMarketingVoucherQueryModel, AlipayMarketingVoucherQueryRequest
from alipay.aop.api.request.AlipayUserDtbankcustChannelvoucherSendRequest import AlipayUserDtbankcustChannelvoucherSendModel, AlipayUserDtbankcustChannelvoucherSendRequest
from alipay.aop.api.request.AlipayFundTransUniTransferRequest import AlipayFundTransUniTransferModel, AlipayFundTransUniTransferRequest
from alipay.aop.api.request.AlipayFundTransCommonQueryRequest import AlipayFundTransCommonQueryModel, AlipayFundTransCommonQueryRequest
from alipay.aop.api.request.AlipayMarketingSharetokenCreateRequest import AlipayMarketingSharetokenCreateModel, AlipayMarketingSharetokenCreateRequest
from alipay.aop.api.request.AlipayUserDtbankcustActivityconfigQueryRequest import AlipayUserDtbankcustActivityconfigQueryModel, AlipayUserDtbankcustActivityconfigQueryRequest
from alipay.aop.api.request.AlipayUserDtbankcustActivityorderQueryRequest import AlipayUserDtbankcustActivityorderQueryModel, AlipayUserDtbankcustActivityorderQueryRequest


def client():
    '''实例化阿里云对象'''
    # logging.basicConfig(
    #     level=logging.INFO,
    #     format='%(asctime)s %(levelname)s %(message)s',
    #     filemode='a', )
    # logger = logging.getLogger('')

    alipay_client_config = AlipayClientConfig()
    alipay_client_config.server_url = 'https://openapi.alipay.com/gateway.do'
    alipay_client_config.app_id = '2021002100623180'
    alipay_client_config.app_cert_sn = 'd9834d28779b854e8393ab6895f61d88'
    alipay_client_config.alipay_root_cert_sn = '687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6'
    alipay_client_config.app_private_key = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'certificate/app_private_key.pem'), 'r').read()
    alipay_client_config.alipay_public_key = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'certificate/alipay_public_key.pem'), 'r').read()
    client = CertDefaultAlipayClient(alipay_client_config)
    return client

app_id = '2021002100623180'
app_private_key = 'MIIEogIBAAKCAQEAhajVywUhgFI7hAZO4q8HK5DOdLlq0bIvXuxL5QLQj8Zx46KFHxbDgy8FUjpIwCzfHeQpxHvbedcnzocfY6MeCqwyFMV7vClTcz23idW74lUEus0feEPfLx3AHccl8nHjOCnSzvKh3kd9zLnmNPIy0N5JnLSnREgZ9QULS7L9E6SAy3dh2VOy+1WOJrbjqod7+9Eq/kzZgkDD5G2SvP2ftgA9XgPw+uc/+7BmaS0IsC2kDeeKDW2ceysGD5+GSPSFc9MLOdK+0OlBaeAHRpphvgYfBbIFKxbsDOr/1htn0qeAc2XIW298fwVWE+0EPAlfOWQpxToFX39mushQdQE1kwIDAQABAoIBAHJkj6XUXFnRB3L1WyqTllVo9+naj1utXvGk10fHYuzKcMrcW4bCGs75vVok3ALt5H9WuZCaWLsss7sE1o6WGq4TtkEky8O8stlcpurm7IjHLucZi6eIn0lZ8wUJXqbjZg65bN0FuBffpAFF0YrbBzbQKLxfuRCtjNmxWXuOUx8tXIY3uTuWY+Yt7O34Bub6JHv5R7o8j6wjGoDAsa3s8N61XYOi1r/CgiGqutY4F9CLZUItjawVTXGpQimnZcNMRbTLTyA+7KWmqs2r8+vQCCMj6nXCx7EdtU6Q5XtNtAGYHhQ6KRSk0TV1IQ1dwbE7hXM+K0QHln6YZ2T3f6Au9gECgYEAxD3j9EDbQASvLHgEorv4l8I+LtIMnMDlW28eolX2tWk5YnROiTmjWSTWEN5G0nIId6I5p9tCfcHJLkUer+kQ/l2udq5EMs1s1V0eLCpsCThF4VcajEnuJ3r+zbUH+oI0vy16f+l0xq0QuQh0ejAEEAFs0UitUeWY5SQrExUdtxMCgYEArlxRric8sG4aKI8GuM7JjTuVXBgTiXl6ad+u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ucherclient():
    '''实例化阿里云对象'''
    # logging.basicConfig(
    #     level=logging.INFO,
    #     format='%(asctime)s %(levelname)s %(message)s',
    #     filemode='a', )
    # logger = logging.getLogger('')

    alipay_client_config = AlipayClientConfig()
    alipay_client_config.server_url = 'https://openapi.alipay.com/gateway.do'
    alipay_client_config.app_id = '2021001164607333'
    # alipay_client_config.app_cert_sn = '354355316408997d18f382d9324c3334'
    # alipay_client_config.alipay_root_cert_sn = '687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6'
    alipay_client_config.app_private_key = 'MIIEogIBAAKCAQEAhajVywUhgFI7hAZO4q8HK5DOdLlq0bIvXuxL5QLQj8Zx46KFHxbDgy8FUjpIwCzfHeQpxHvbedcnzocfY6MeCqwyFMV7vClTcz23idW74lUEus0feEPfLx3AHccl8nHjOCnSzvKh3kd9zLnmNPIy0N5JnLSnREgZ9QULS7L9E6SAy3dh2VOy+1WOJrbjqod7+9Eq/kzZgkDD5G2SvP2ftgA9XgPw+uc/+7BmaS0IsC2kDeeKDW2ceysGD5+GSPSFc9MLOdK+0OlBaeAHRpphvgYfBbIFKxbsDOr/1htn0qeAc2XIW298fwVWE+0EPAlfOWQpxToFX39mushQdQE1kwIDAQABAoIBAHJkj6XUXFnRB3L1WyqTllVo9+naj1utXvGk10fHYuzKcMrcW4bCGs75vVok3ALt5H9WuZCaWLsss7sE1o6WGq4TtkEky8O8stlcpurm7IjHLucZi6eIn0lZ8wUJXqbjZg65bN0FuBffpAFF0YrbBzbQKLxfuRCtjNmxWXuOUx8tXIY3uTuWY+Yt7O34Bub6JHv5R7o8j6wjGoDAsa3s8N61XYOi1r/CgiGqutY4F9CLZUItjawVTXGpQimnZcNMRbTLTyA+7KWmqs2r8+vQCCMj6nXCx7EdtU6Q5XtNtAGYHhQ6KRSk0TV1IQ1dwbE7hXM+K0QHln6YZ2T3f6Au9gECgYEAxD3j9EDbQASvLHgEorv4l8I+LtIMnMDlW28eolX2tWk5YnROiTmjWST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rPt78vMFvjTBDQm4Lkx0eNRzfaNRLrQ5h+e+sUKlsD+LZgMh+xZBmyF6NMujfZ+jJiGlU4FAHSovCupGNZsKrxr5Criv3kQqw+VR7fr4LC6rTYxk9RmFSu+/L2R6lCPWgWC6LXeJ5Ab03KSyaStJywIDAQAB'
    client = CertDefaultAlipayClient(alipay_client_config)
    return client

def voucherclient_jiangxi88():
    '''实例化阿里云对象'''
    # logging.basicConfig(
    #     level=logging.INFO,
    #     format='%(asctime)s %(levelname)s %(message)s',
    #     filemode='a', )
    # logger = logging.getLogger('')

    alipay_client_config = AlipayClientConfig()
    alipay_client_config.server_url = 'https://openapi.alipay.com/gateway.do'
    alipay_client_config.app_id = '2021004130693973'
    # alipay_client_config.app_cert_sn = '354355316408997d18f382d9324c3334'
    # alipay_client_config.alipay_root_cert_sn = '687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6'
    alipay_client_config.app_private_key = 'MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCKGfggTliFOAlHR7tfdVRxcKit72o72oppiYvzj7/rr0x1K+9jW5ZMYyZ2Q2kgqcHzBgGLS/ItX+K1SxWuaFufZTBNdhPLfZBhQ4Bn+ENHB+giGx3Uw5AZJb1EkYRzlqkpQ0YL4vBd8FJXpKms+NkVLt4/IK05STIDXHC4ml5MotdUhIiunyedRSwrnVQABmupiCOC+uZKNzsBYQwEj8vOMvCA+BKvKRkwtxKywMYXcNXtAUkepSJqqcNolVS/tjSsL6HxE8NUNbaoPP2eQvLr6DjjrQkVAujEVNmzJfExqt+TcOdxbU4qW99TNyhfhkDIjJzJuCj/T8ENpvGQYlHjAgMBAAECggEAQBMSe7K+AXlhXLAccIrYlhWGPcVSTdj01UibJXNxwWFBITA0Tq4kyuZJ5x8ZvKzmruH/f2jKQWE2p5Thx1zl/cuOILKDNqvYfDg8cIDQfjld680XByuBRRmseg7mHFcvv1RWQJeXnI4vNjjQ/M8ssVZgiXuYw3aBfOu75PrCe91y74sDkxK4OrOKswqQhZgOcpNMhXoatrSP1xIk4ss8sJepWZsQt7SekFB+q6BlcNGE2W4As7GNiilIAC012LyxpSMATHMtY54edhGE2z6Bl2BE4Gt2Fydrtd/WiUXbWz8iUU0qkeVPvtXyzvaxTfhmEsaW1Zd1WH0lu761hXM3IQKBgQDsMd8OgexQ071OYJqxrf+QYh5XVjLstFdGmw4Pc2zi89GTKVUP3OhvmHUsuvWKl+flhmbSVZKgqQWpellOut9dALoCxlAQepplR5xx77x633/29+v2gDWydn+B6qW/N4KGhrfzSzQdmf1HxbLNZKjbPbvlW5PNSJav6TOW9hsBkwKBgQCVrnAS5YeC/yVESnK8/adqyS3gvqU8b1AeMf232cRb3jVECmech+8pxr0lVmyVjBaRdXkH1R4upTPoJP/AOZJvFsXATy54oAp7suHNhW2zh86w1BogLEYlOkNCZ/jpXq+ljO7e7Jh2oo6vWrhkROE384bTQybM4kmlg2obhFLgcQKBgQCsjF5cldOS1KyWRoKcTPXHf7aUrRc0zyZ3IS0rYnJodiBjdq16kjKH3AO18rsQTZsOlZomDHe6wN+vCP+XQXON2MsK3d99umNym9cRcUbrKL2uKT4LbWxM/L53pXkCcUX8iwx1QzpGacmbljTiUaf9ymKq0rTuIhpbVmzm2tGt2wKBgQCJYxVnotphOMQCDLuIEOKsN4Auu457DEjjjksth2qeUDVgAJTdrj+tfsd6D/uWwICufr7am5kag3RDbkJ5M97erG5Sd9tVyMAWjjiIJiJtGQh0chqQ0VKJNRMrTre/rLNYJyXR5CSFL+v7tC9viXGXo6VrIEXq5QFoNFkebLSNYQKBgQDCAaoRuN6dAtT3jENtZeqzq5UylA4Y7yvRD6AE1ywIkxUM49dpIU1a2smhxgdlKxZW+hKSnRc3vk5Jax/N/2/ytYuJKiipHuMQWzEiA5iKnwikVX/XbvOZ1VrCNkpLEgBLbivVpuW9plrpvOUL32SWhSuyD319ZIchBcnKZeM3kA=='
    alipay_client_config.alipay_public_key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnUZRUNEZLvTx43M9R/5i+MrK4PzibTFHH6Yfj/YVruR2Il8ZsNSNd4WD8SynE06o7jCC4fx22L2jBQRGt6Cv4F6ddgS5zd8yaOoWXYf94iZl06/oK1HII9iQjK0OLVkcLoVOjvJu3k/nE8n1rQ5Bw3pdOdbxP6rJk78rDPUQOQv+qtCex5ZLHmUxlDht0LLm4/RGlNjGi2+3z0e5O9+vvM0nJt9RcjbBdE+lKD+n/NCvS8fNrU9PSua9rH4sMMTvjNVINCBmdWxLOy+8KozNn0VGxefnXHtEHBJI0FtECfD5rf0D6F5Rs51Is+d3dLXowAxQFjJhktiQRxTjZ86DPwIDAQAB'
    client = CertDefaultAlipayClient(alipay_client_config)
    return client

def client_jiangxi88():
    '''实例化阿里云对象'''
    alipay_client_config = AlipayClientConfig()
    alipay_client_config.server_url = 'https://openapi.alipay.com/gateway.do'
    alipay_client_config.app_id = '2021004128623106'
    alipay_client_config.app_cert_sn = '58b49835e0994e963e955d7acc47476d'
    alipay_client_config.alipay_root_cert_sn = '687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6'
    alipay_client_config.app_private_key = 'MIIEpAIBAAKCAQEAkBEldvlKD25wftvk0n2+wezS47ACxEKbvFnZ4aU5Xs/hfEPyIG09k8/l2XuEQJ2iqPK7a9pG1N4ONnlG91MWwL8gTb+OhsmuVfI4EkqA2elAbDNC6nBORINQgoMH2gi96RO4IykaIFe2K3UnwpibYDbkQ3CVXvOzN1CgeOd8/KuKfGSBmeQkwYMpU7kYKAxyShc9ykIcn1bZucUGzFD+Sdq2/H7J7MWVmUal+mU5d5DXzfmYD6c5pANpRRKSGtaSZ1vld94v41tBe7UkQSfmIzKZNJsJHCIUHYoNny38QpuWQi0Ps0ivvxwPSRghlFG81s1fFJNk2FIkl4wLMxYcpQIDAQABAoIBAHt/d1JJ2QbpcV4OOlWGnaO31ACCvZxoTQBlNbWM4WU5Zt4TkNfjTUo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RA4x54KEI5sDLFVdVM+uintQPyGp2LwPRzyzs8skdER9lOci9g8eI+QxhVh9d2BZwh7dRM/wBIl+LgktvMik3qyNQvaTCZw2h75Q=='
    alipay_client_config.alipay_public_key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnUZRUNEZLvTx43M9R/5i+MrK4PzibTFHH6Yfj/YVruR2Il8ZsNSNd4WD8SynE06o7jCC4fx22L2jBQRGt6Cv4F6ddgS5zd8yaOoWXYf94iZl06/oK1HII9iQjK0OLVkcLoVOjvJu3k/nE8n1rQ5Bw3pdOdbxP6rJk78rDPUQOQv+qtCex5ZLHmUxlDht0LLm4/RGlNjGi2+3z0e5O9+vvM0nJt9RcjbBdE+lKD+n/NCvS8fNrU9PSua9rH4sMMTvjNVINCBmdWxLOy+8KozNn0VGxefnXHtEHBJI0FtECfD5rf0D6F5Rs51Is+d3dLXowAxQFjJhktiQRxTjZ86DPwIDAQAB'
    client = CertDefaultAlipayClient(alipay_client_config)
    return client

def client_jiangxi88_jizhangben():
    '''实例化阿里云对象'''
    alipay_client_config = AlipayClientConfig()
    alipay_client_config.server_url = 'https://openapi.alipay.com/gateway.do'
    alipay_client_config.app_id = '2021002191691230'
    alipay_client_config.app_cert_sn = '242800f354f50ef5d2d8a600382ebb31'
    alipay_client_config.alipay_root_cert_sn = '687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6'
    alipay_client_config.app_private_key = 'MIIEowIBAAKCAQEAkOGzZAHGo0PKX8wgNFrnEl+2wwRsqu6Iuy4Z4JetH3xE9Xe6YdqFG3KdnKjuRWmljZYirW9wYvB8RDvJTKyevCV4gmt8cnD1e5KlyMRdlvFTf3itK/1VS9FFZQnzAUTK05PXv7DaZ39GIp18xo1kZ0KNyDJxYrx3fWBLxpMhTbIYRMRLaS/nX84yRl/s2r1jikxNZMqrXO64vyaNpix/31IWuOTcu2Z/fAkX9ZCMUZ4EL/avQhnGBHCRbh3l2kMJKb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cBisXx6ozRmITbHUrz16WAlccl1h/WFg/3AZp+kFKPark0Wyhx7AEF4QKBgA+Tq0Ie5Pa/eL90p9fGfiCpXsTrDnSXHW0MT0YPfz5SNbDlu4czJwrx38Mgs15T6lFhzvX7tTqsXYfWm9Hn79sljwr4twR7TYFSHsM1LrvqeD3FGCW9Yds90ryCFtWmi11xQUBn5yFAupLh0iuZl0YT1QXUdRv6eZEE+E+2wkfd'
    alipay_client_config.alipay_public_key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAobteo0zpnIqs1lq+0Isiqu6YwVpTK9AS2MLCkmJyArVuFOMseJvOBbMGiY3YFB6j9kgfYtTb2tkrQxVu2TsCE9yODGxWYqH0PIxGZ7BbzckLooqlGwXK0u+6ToldsrlZ3nDQs+7Ck/nj5HCFKk3RfJtEJ/878dlumJacq8j+8yLGtMVlZhT8RmfUMTCHjKd/uXjCn87RbdG9nrY9slI4+CQtcpIS40PBrj1qwVQkVJHCyruwMRrpCxq4qEC/fqzj4EcmPiItNsv6r3MFXxIWokCzlRcCkY/ovPIXgjzbTxcCOaZv6qqFzmNMEaQC1Q5fxut5Z80zriAi6plBUR8NZwIDAQAB'
    client = CertDefaultAlipayClient(alipay_client_config)
    return client


client = client()
voucherclient = voucherclient()
voucherclient_jiangxi88 = voucherclient_jiangxi88()
client_jiangxi88 = client_jiangxi88()
client_jiangxi88_jizhangben = client_jiangxi88_jizhangben()


class AlipayOpen():

    def __init__(self):

        self.client = client
        self.voucherclient = voucherclient
        self.voucherclient_jiangxi88 = voucherclient_jiangxi88

    def systemoauthtoken(self, code):
        request = AlipaySystemOauthTokenRequest()
        request.grant_type = 'authorization_code'
        request.code = code
        response_content = self.client.execute(request)
        return response_content

    def vouchersend(self, user_id, activity_id, out_biz_no):
        model = AlipayUserDtbankcustChannelvoucherSendModel()
        model.activity_id = activity_id
        model.user_id = user_id
        model.out_biz_no = out_biz_no
        request = AlipayUserDtbankcustChannelvoucherSendRequest(biz_model=model)
        response_content = self.voucherclient.execute(request)
        return response_content

    def vouchersend_login_id(self, user_id, activity_id, out_biz_no):
        model = AlipayUserDtbankcustChannelvoucherSendModel()
        model.activity_id = activity_id
        model.login_id = user_id
        model.out_biz_no = out_biz_no
        request = AlipayUserDtbankcustChannelvoucherSendRequest(biz_model=model)
        response_content = self.voucherclient.execute(request)
        return response_content

    def voucherquery(self, voucher_id):
        model = AlipayMarketingVoucherQueryModel()
        model.voucher_id = voucher_id
        request = AlipayMarketingVoucherQueryRequest(biz_model=model)
        response_content = self.voucherclient.execute(request)
        return response_content

    def transunitransfer(self, user_id, out_biz_no, trans_amount, order_title):
        model = AlipayFundTransUniTransferModel()
        model.alipay_user_id = '2088631976752358'
        model.account_type = 'ACCTRANS_ACCOUNT'
        model.out_biz_no = out_biz_no
        model.trans_amount = str(trans_amount)
        model.product_code = 'TRANS_ACCOUNT_NO_PWD'
        model.biz_scene = 'DIRECT_TRANSFER'
        model.app_cert_sn = 'DIRECT_TRANSFER'
        payeeInfo = {
            "identity_type": "ALIPAY_USER_ID",
            "identity": user_id
        }
        model.payee_info = payeeInfo
        model.order_title = order_title
        model.remark = order_title
        model.business_params = {
            "payer_show_name_use_alias": True
        }
        request = AlipayFundTransUniTransferRequest(biz_model=model)
        response_content = self.client.execute(request)
        return response_content

    def transunitransferquery(self, order_id):
        model = AlipayFundTransCommonQueryModel()
        model.order_id = order_id
        model.product_code = 'TRANS_ACCOUNT_NO_PWD'
        model.biz_scene = 'DIRECT_TRANSFER'
        request = AlipayFundTransCommonQueryRequest(biz_model=model)
        response_content = self.client.execute(request)
        return response_content

    def sharetoken(self, btn_right_href):
        model = AlipayMarketingSharetokenCreateModel()
        model.biz_type = 'COUPON_TOOL'
        model.biz_linked_id = '20230620124230124500'
        model.title = '广西手机银行5元券'
        model.timeout = 120*3600*24
        model.desc = '满5.01元可用'
        model.icon = 'https://jinjian.sutpay.cn/20230905094237.png'
        model.btn_left = '取消'
        model.btn_right = '点击参与'
        model.btn_right_href = btn_right_href
        request = AlipayMarketingSharetokenCreateRequest(biz_model=model)
        response_content = self.voucherclient.execute(request)
        return response_content

    def activityconfig_query(self, activity_id):
        model = AlipayUserDtbankcustActivityconfigQueryModel()
        model.activity_type = 'VOUCHER'
        model.activity_id = activity_id
        request = AlipayUserDtbankcustActivityconfigQueryRequest(biz_model=model)
        response_content = self.voucherclient.execute(request)
        return response_content

    def activityorder_query(self, activity_id, out_biz_no, logon_id):
        model = AlipayUserDtbankcustActivityorderQueryModel()
        model.activity_id = activity_id
        model.logon_id = logon_id
        model.out_biz_no = out_biz_no
        request = AlipayUserDtbankcustActivityorderQueryRequest(biz_model=model)
        response_content = self.voucherclient.execute(request)
        return response_content